<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    ul {
        /* 去除列表前面的点 */
        list-style-type: none;
        /* 鼠标移动到ul列表 会改变鼠标样式 */
        cursor: pointer; 
    }
    </style>
</head>

<body>
    <ul id="ulId">
        <li>java</li>
        <li>C</li>
        <li>C++</li>
        <li>js</li>
        <li>Python</li>
        <li>PHP</li>
        <li>Vue.js</li>
        <li>Go</li>
    </ul>
    <script>
        function my$(id) {
            return document.getElementById(id);
        }
        var liObjs = my$("ulId").getElementsByTagName("li");
        for (let lObjet of liObjs) {
            //鼠标进入事件
            lObjet.onmouseover = function () {
              this.style.backgroundColor = "red"
            }
            //鼠标离开时间
            lObjet.onmouseout = function (){
                this.style.backgroundColor = ""
            }
        }    

    </script>
</body>

</html>